Ext.define('Admin.view.tender.TenderController', {

    extend: 'Admin.ux.GridController',

    alias: 'controller.tender',


    //新增
    addButton: function(b,opts) {

        var me = this;
        var form = b.up("form").getForm();
        var viewModel = me.getViewModel();
        form.submit({
            clientValidation: true,
            url:'/tender/add',
            params:form.getFieldValues(),
            success:function(form,action){
                me.redirectTo('tender-view', true);
            },
            failure:function(form,action){
                switch (action.failureType) {
                    case Ext.form.action.Action.CLIENT_INVALID:
                        Ext.create('Admin.ux.Action').error('客户端验证不通过');
                        break;
                    default:
                        viewModel.set("error",action.result.msg+"!");
                }
            }
        });
    },
    //新增
    addAction: function (b) {
        var me = this;
        var win = Ext.create("Admin.ux.Window", {
            width: 710,
            height: 550,
            animateTarget: b,
            items: {xtype: 'tender-form'},
            buttons: [
                {
                    text: '重置',
                    ui: 'soft-red',
                    iconCls: 'x-fa 	fa-mail-reply',
                    handler: function (btn) {
                        btn.up("window").down("form").reset();
                    }
                },
                {
                    text: '取消',
                    ui: 'gray',
                    iconCls: 'x-fa 	fa-ban',
                    handler: function (btn) {
                        btn.up("window").close();
                    }
                }
            ]
        });
    },
    //新增
    addSectionAction: function (b,tenderId) {
        var me = this;
        var win = Ext.create("Admin.ux.Window", {
            width: 710,
            height: 550,
            animateTarget: b,
            items: {xtype: 'tendersection-form'},
            buttons: [
                {
                    text: '保存',
                    ui: 'soft-green',
                    iconCls: 'x-fa 	fa-floppy-o',
                    handler: function (btn) {
                        var form = btn.up("window").down("form").getForm();
                        form.setAttribute("tenderId",tenderId);
                        Ext.create('Admin.ux.Action').submit(form,'/tender/sectionAdd',me.getView(),win);
                    }
                },
                {
                    text: '重置',
                    ui: 'soft-red',
                    iconCls: 'x-fa 	fa-mail-reply',
                    handler: function (btn) {
                        btn.up("window").down("form").reset();
                    }
                },
                {
                    text: '取消',
                    ui: 'gray',
                    iconCls: 'x-fa 	fa-ban',
                    handler: function (btn) {
                        btn.up("window").close();
                    }
                }
            ]
        });
    },
    //新增
    addSectionAction: function (b,tenderId) {
        var me = this;
        var win = Ext.create("Admin.ux.Window", {
            width: 710,
            height: 550,
            animateTarget: b,
            items: {xtype: 'tendersection-form'},
            buttons: [
                {
                    text: '保存',
                    ui: 'soft-green',
                    iconCls: 'x-fa 	fa-floppy-o',
                    handler: function (btn) {
                        var form = btn.up("window").down("form").getForm();
                        form.setAttribute("tenderId",tenderId);
                        Ext.create('Admin.ux.Action').submit(form,'/tender/sectionAdd',me.getView(),win);
                    }
                },
                {
                    text: '重置',
                    ui: 'soft-red',
                    iconCls: 'x-fa 	fa-mail-reply',
                    handler: function (btn) {
                        btn.up("window").down("form").reset();
                    }
                },
                {
                    text: '取消',
                    ui: 'gray',
                    iconCls: 'x-fa 	fa-ban',
                    handler: function (btn) {
                        btn.up("window").close();
                    }
                }
            ]
        });
    },
    //编辑行
    bbAction: function (grid, rowIndex, colIndex, item, e, record, row) {

        var rec = grid.getStore().getAt(rowIndex);

        var me = this;

        var win = Ext.create("Admin.ux.Window", {
            width: 710,
            height: 550,
            animateTarget: row,
            items: {xtype: 'tenderpeople-form'},
            buttons: [
                {
                    text: '保存',
                    ui: 'soft-green',
                    iconCls: 'x-fa 	fa-floppy-o',
                    handler: function (btn) {
                        var form = btn.up("window").down("form").getForm();
                        // Ext.create('Admin.ux.Action').submit(form,'/user/edit',me.getView(),win);
                    }
                },
                {
                    text: '重置',
                    ui: 'soft-red',
                    iconCls: 'x-fa 	fa-mail-reply',
                    handler: function (btn) {
                        /* var form = btn.up("window").down("form");
                         form.getForm().load({
                             url: '/user/get',
                             waitMsg:'加载中...',
                             params: {
                                 id: rec.get('id')
                             },
                             success:function(){
                                 form.down('textfield[id=user_id]').setReadOnly(true);
                             },
                             failure: function(form, action) {
                                 if(action.result.msg!=undefined){
                                     Ext.Msg.alert("提示", "<font color=red>"+action.result.msg+"!</font>");
                                 }else{
                                     Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                 }
                             }
                         });
                         form.loadRecord(rec);*/

                        var treeMenu = new Ext.menu.Menu
                        ([
                            {
                                xtype: "button",
                                text: "添加",
                                icon: "Images/Icons/button/add.gif",
                                pressed: true,
                                handler: function () {
                                }
                            },
                            {
                                xtype: "button",
                                text: "编辑",
                                icon: "Images/Icons/button/delete.gif",
                                pressed: true,
                                handler: function () {
                                }
                            },
                            {
                                xtype: "button",
                                text: "隐藏",
                                icon: "Images/Icons/arrow-down.gif",
                                pressed: true,
                                handler: function () {
                                }
                            },
                            {
                                xtype: "button",
                                text: "显示",
                                icon: "Images/Icons/arrow-up.gif",
                                pressed: true,
                                handler: function () {
                                }
                            },
                            {
                                xtype: "button",
                                text: "删除",
                                icon: "Images/Icons/button/cross.gif",
                                pressed: true,
                                handler: function () {
                                }
                            },
                            {
                                xtype: "button",
                                text: "上传图片",
                                icon: "Images/Icons/plugin_add.gif",
                                pressed: true,
                                handler: function () {
                                }
                            }
                        ]);
                        treeMenu.showAt(btn.getPoint());
                    }
                },
                {
                    text: '取消',
                    ui: 'gray',
                    iconCls: 'x-fa 	fa-ban',
                    handler: function (btn) {
                        btn.up("window").close();
                    }
                }
            ]
        });

    },

    moreAction: function (grid, rowIndex, colIndex, item, e, record, row) {

        var rec = grid.getStore().getAt(rowIndex);

        var me = this;

        var treeMenu = new Ext.menu.Menu({
            shadow: "drop",
            allowOtherMenus: true,
            items: [
                new Ext.menu.Item({
                    text: "编辑",
                    iconCls: 'array-grid-buy-col',
                    handler: function () {
                        var win = Ext.create("Admin.ux.Window",{
                            title:'编辑招标信息',
                            width:710,
                            height:550,
                            animateTarget: row,
                            items:{xtype:'tenderedit-form'},
                            buttons:[
                                {
                                    text:'保存',
                                    ui: 'soft-green',
                                    iconCls: 'x-fa 	fa-floppy-o',
                                    handler:function(btn){
                                        var form = btn.up("window").down("form").getForm();
                                        Ext.create('Admin.ux.Action').submit(form,'/tender/edit',me.getView(),win);
                                    }
                                },
                                {
                                    text:'重置',
                                    ui: 'soft-red',
                                    iconCls: 'x-fa 	fa-mail-reply',
                                    handler:function(btn){
                                        var form = btn.up("window").down("form");
                                        form.getForm().load({
                                            url: '/tender/get',
                                            waitMsg:'加载中...',
                                            params: {
                                                id: rec.get('id')
                                            },
                                            success:function(){
                                                form.down('textfield[id=id]').setReadOnly(true);
                                            },
                                            failure: function(form, action) {
                                                if(action.result.msg!=undefined){
                                                    Ext.Msg.alert("提示", "<font color=red>"+action.result.msg+"!</font>");
                                                }else{
                                                    Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                                }
                                            }
                                        });
                                        form.loadRecord(rec);
                                    }
                                },
                                {
                                    text:'取消',
                                    ui: 'gray',
                                    iconCls: 'x-fa 	fa-ban',
                                    handler:function(btn){
                                        btn.up("window").close();
                                    }
                                }
                            ],

                            listeners:{
                                show:function(w,opts){

                                    var form = this.down('form');

                                    form.getForm().load({
                                        url: '/tender/get',
                                        waitMsg:'加载中...',
                                        params: {
                                            id: rec.get('id')
                                        },
                                        success:function(){
                                            form.down('textfield[id=id]').setReadOnly(true);
                                        },
                                        failure: function(form, action) {
                                            if(action.result.msg!=undefined){
                                                Ext.Msg.alert("提示", "<font color=red>"+action.result.msg+"!</font>");
                                            }else{
                                                Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                            }
                                        }
                                    });
                                }
                            }
                        });
                    }
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "编辑标段标包",
                    iconCls: 'array-grid-buy-col',
                    handler: function () {
                        var win = Ext.create("Admin.ux.Window", {
                            title: '编辑标段标包',
                            width: 710,
                            height: 550,
                            animateTarget: row,
                            items: {xtype: 'tendersection-view'},

                            listeners: {
                                show: function (w, opts) {
                                    var store = me.up("grid").getStore();
                                    /*store.loadPage(1,{
                                        params : {
                                            keywords : me.getValue()
                                        }
                                    });*/
                                    Ext.apply(store.proxy.extraParams,{tenderId : rec.get('id')});
                                    store.removeAll();
                                    store.loadPage(1);
                                }
                            }
                        });
                    }
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "审核",
                    iconCls: 'array-grid-buy-col',
                    handler: function () {
                        var win = Ext.create("Admin.ux.Window", {
                            title: '审核',
                            width: 710,
                            height: 550,
                            animateTarget: row,
                            items: {xtype: 'tenderedit-form'},
                            buttons: [
                                {
                                    text: '审核通过',
                                    ui: 'soft-green',
                                    iconCls: 'x-fa 	fa-floppy-o',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form").getForm();
                                        Ext.create('Admin.ux.Action').submit(form, '/tender/exam', me.getView(), win);
                                    }
                                },
                                {
                                    text: '重置',
                                    ui: 'soft-red',
                                    iconCls: 'x-fa 	fa-mail-reply',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form");
                                        form.getForm().load({
                                            url: '/tender/get',
                                            waitMsg: '加载中...',
                                            params: {
                                                id: rec.get('id')
                                            },
                                            success: function () {
                                                form.down('textfield[id=id]').setReadOnly(true);
                                            },
                                            failure: function (form, action) {
                                                if (action.result.msg != undefined) {
                                                    Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                                } else {
                                                    Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                                }
                                            }
                                        });
                                        form.loadRecord(rec);
                                    }
                                },
                                {
                                    text: '取消',
                                    ui: 'gray',
                                    iconCls: 'x-fa 	fa-ban',
                                    handler: function (btn) {
                                        btn.up("window").close();
                                    }
                                }
                            ],

                            listeners: {
                                show: function (w, opts) {

                                    var form = this.down('form');

                                    form.getForm().load({
                                        url: '/tender/get',
                                        waitMsg: '加载中...',
                                        params: {
                                            id: rec.get('id')
                                        },
                                        success: function () {
                                            form.down('textfield[id=id]').setReadOnly(true);
                                        },
                                        failure: function (form, action) {
                                            if (action.result.msg != undefined) {
                                                Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                            } else {
                                                Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                            }
                                        }
                                    });
                                }
                            }
                        });
                    }
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "浏览",
                    iconCls: 'array-grid-buy-col',
                    handler: function () {
                        window.open("http://140.143.121.69/TenderWeb/ControlView/_ViewNotice?id=" + rec.get('id'));
                    }
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "发布二次公告",
                    iconCls: 'array-grid-buy-col',
                    handler: function () {
                        var win = Ext.create("Admin.ux.Window", {
                            title: '发布二次公告',
                            width: 710,
                            height: 550,
                            animateTarget: row,
                            items: {xtype: 'tenderedit-form'},
                            buttons: [
                                {
                                    text: '保存',
                                    ui: 'soft-green',
                                    iconCls: 'x-fa 	fa-floppy-o',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form").getForm();
                                        Ext.create('Admin.ux.Action').submit(form, '/tender/edit', me.getView(), win);
                                    }
                                },
                                {
                                    text: '重置',
                                    ui: 'soft-red',
                                    iconCls: 'x-fa 	fa-mail-reply',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form");
                                        form.getForm().load({
                                            url: '/tender/get',
                                            waitMsg: '加载中...',
                                            params: {
                                                id: rec.get('id')
                                            },
                                            success: function () {
                                                form.down('textfield[id=id]').setReadOnly(true);
                                            },
                                            failure: function (form, action) {
                                                if (action.result.msg != undefined) {
                                                    Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                                } else {
                                                    Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                                }
                                            }
                                        });
                                        form.loadRecord(rec);
                                    }
                                },
                                {
                                    text: '取消',
                                    ui: 'gray',
                                    iconCls: 'x-fa 	fa-ban',
                                    handler: function (btn) {
                                        btn.up("window").close();
                                    }
                                }
                            ],

                            listeners: {
                                show: function (w, opts) {

                                    var form = this.down('form');

                                    form.getForm().load({
                                        url: '/tender/get',
                                        waitMsg: '加载中...',
                                        params: {
                                            id: rec.get('id')
                                        },
                                        success: function () {
                                            form.down('textfield[id=id]').setReadOnly(true);
                                        },
                                        failure: function (form, action) {
                                            if (action.result.msg != undefined) {
                                                Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                            } else {
                                                Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                            }
                                        }
                                    });
                                }
                            }
                        });
                    }
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "发布变更",
                    iconCls: 'array-grid-buy-col',
                    handler: function () {
                        var win = Ext.create("Admin.ux.Window", {
                            title: '发布变更',
                            width: 710,
                            height: 550,
                            animateTarget: row,
                            items: {xtype: 'tenderedit-form'},
                            buttons: [
                                {
                                    text: '保存',
                                    ui: 'soft-green',
                                    iconCls: 'x-fa 	fa-floppy-o',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form").getForm();
                                        Ext.create('Admin.ux.Action').submit(form, '/tender/edit', me.getView(), win);
                                    }
                                },
                                {
                                    text: '重置',
                                    ui: 'soft-red',
                                    iconCls: 'x-fa 	fa-mail-reply',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form");
                                        form.getForm().load({
                                            url: '/tender/get',
                                            waitMsg: '加载中...',
                                            params: {
                                                id: rec.get('id')
                                            },
                                            success: function () {
                                                form.down('textfield[id=id]').setReadOnly(true);
                                            },
                                            failure: function (form, action) {
                                                if (action.result.msg != undefined) {
                                                    Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                                } else {
                                                    Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                                }
                                            }
                                        });
                                        form.loadRecord(rec);
                                    }
                                },
                                {
                                    text: '取消',
                                    ui: 'gray',
                                    iconCls: 'x-fa 	fa-ban',
                                    handler: function (btn) {
                                        btn.up("window").close();
                                    }
                                }
                            ],

                            listeners: {
                                show: function (w, opts) {

                                    var form = this.down('form');

                                    form.getForm().load({
                                        url: '/tender/get',
                                        waitMsg: '加载中...',
                                        params: {
                                            id: rec.get('id')
                                        },
                                        success: function () {
                                            form.down('textfield[id=id]').setReadOnly(true);
                                        },
                                        failure: function (form, action) {
                                            if (action.result.msg != undefined) {
                                                Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                            } else {
                                                Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                            }
                                        }
                                    });
                                }
                            }
                        });
                    }
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "发布澄清",
                    iconCls: 'array-grid-buy-col',
                    handler: function () {
                        var win = Ext.create("Admin.ux.Window", {
                            title: '发布澄清',
                            width: 710,
                            height: 550,
                            animateTarget: row,
                            items: {xtype: 'tenderedit-form'},
                            buttons: [
                                {
                                    text: '保存',
                                    ui: 'soft-green',
                                    iconCls: 'x-fa 	fa-floppy-o',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form").getForm();
                                        Ext.create('Admin.ux.Action').submit(form, '/tender/edit', me.getView(), win);
                                    }
                                },
                                {
                                    text: '重置',
                                    ui: 'soft-red',
                                    iconCls: 'x-fa 	fa-mail-reply',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form");
                                        form.getForm().load({
                                            url: '/tender/get',
                                            waitMsg: '加载中...',
                                            params: {
                                                id: rec.get('id')
                                            },
                                            success: function () {
                                                form.down('textfield[id=id]').setReadOnly(true);
                                            },
                                            failure: function (form, action) {
                                                if (action.result.msg != undefined) {
                                                    Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                                } else {
                                                    Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                                }
                                            }
                                        });
                                        form.loadRecord(rec);
                                    }
                                },
                                {
                                    text: '取消',
                                    ui: 'gray',
                                    iconCls: 'x-fa 	fa-ban',
                                    handler: function (btn) {
                                        btn.up("window").close();
                                    }
                                }
                            ],

                            listeners: {
                                show: function (w, opts) {

                                    var form = this.down('form');

                                    form.getForm().load({
                                        url: '/tender/get',
                                        waitMsg: '加载中...',
                                        params: {
                                            id: rec.get('id')
                                        },
                                        success: function () {
                                            form.down('textfield[id=id]').setReadOnly(true);
                                        },
                                        failure: function (form, action) {
                                            if (action.result.msg != undefined) {
                                                Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                            } else {
                                                Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                            }
                                        }
                                    });
                                }
                            }
                        });
                    }
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "发布中标",
                    iconCls: 'array-grid-buy-col',
                    handler: function () {
                        var win = Ext.create("Admin.ux.Window", {
                            title: '发布中标',
                            width: 710,
                            height: 550,
                            animateTarget: row,
                            items: {xtype: 'tenderedit-form'},
                            buttons: [
                                {
                                    text: '保存',
                                    ui: 'soft-green',
                                    iconCls: 'x-fa 	fa-floppy-o',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form").getForm();
                                        Ext.create('Admin.ux.Action').submit(form, '/tender/edit', me.getView(), win);
                                    }
                                },
                                {
                                    text: '重置',
                                    ui: 'soft-red',
                                    iconCls: 'x-fa 	fa-mail-reply',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form");
                                        form.getForm().load({
                                            url: '/tender/get',
                                            waitMsg: '加载中...',
                                            params: {
                                                id: rec.get('id')
                                            },
                                            success: function () {
                                                form.down('textfield[id=id]').setReadOnly(true);
                                            },
                                            failure: function (form, action) {
                                                if (action.result.msg != undefined) {
                                                    Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                                } else {
                                                    Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                                }
                                            }
                                        });
                                        form.loadRecord(rec);
                                    }
                                },
                                {
                                    text: '取消',
                                    ui: 'gray',
                                    iconCls: 'x-fa 	fa-ban',
                                    handler: function (btn) {
                                        btn.up("window").close();
                                    }
                                }
                            ],

                            listeners: {
                                show: function (w, opts) {

                                    var form = this.down('form');

                                    form.getForm().load({
                                        url: '/tender/get',
                                        waitMsg: '加载中...',
                                        params: {
                                            id: rec.get('id')
                                        },
                                        success: function () {
                                            form.down('textfield[id=id]').setReadOnly(true);
                                        },
                                        failure: function (form, action) {
                                            if (action.result.msg != undefined) {
                                                Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                            } else {
                                                Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                            }
                                        }
                                    });
                                }
                            }
                        });
                    }
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "发布招标结果公示",
                    iconCls: 'array-grid-buy-col',
                    handler: function () {
                        var win = Ext.create("Admin.ux.Window", {
                            title: '发布招标结果公示',
                            width: 710,
                            height: 550,
                            animateTarget: row,
                            items: {xtype: 'tenderedit-form'},
                            buttons: [
                                {
                                    text: '保存',
                                    ui: 'soft-green',
                                    iconCls: 'x-fa 	fa-floppy-o',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form").getForm();
                                        Ext.create('Admin.ux.Action').submit(form, '/tender/edit', me.getView(), win);
                                    }
                                },
                                {
                                    text: '重置',
                                    ui: 'soft-red',
                                    iconCls: 'x-fa 	fa-mail-reply',
                                    handler: function (btn) {
                                        var form = btn.up("window").down("form");
                                        form.getForm().load({
                                            url: '/tender/get',
                                            waitMsg: '加载中...',
                                            params: {
                                                id: rec.get('id')
                                            },
                                            success: function () {
                                                form.down('textfield[id=id]').setReadOnly(true);
                                            },
                                            failure: function (form, action) {
                                                if (action.result.msg != undefined) {
                                                    Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                                } else {
                                                    Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                                }
                                            }
                                        });
                                        form.loadRecord(rec);
                                    }
                                },
                                {
                                    text: '取消',
                                    ui: 'gray',
                                    iconCls: 'x-fa 	fa-ban',
                                    handler: function (btn) {
                                        btn.up("window").close();
                                    }
                                }
                            ],

                            listeners: {
                                show: function (w, opts) {

                                    var form = this.down('form');

                                    form.getForm().load({
                                        url: '/tender/get',
                                        waitMsg: '加载中...',
                                        params: {
                                            id: rec.get('id')
                                        },
                                        success: function () {
                                            form.down('textfield[id=id]').setReadOnly(true);
                                        },
                                        failure: function (form, action) {
                                            if (action.result.msg != undefined) {
                                                Ext.Msg.alert("提示", "<font color=red>" + action.result.msg + "!</font>");
                                            } else {
                                                Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                            }
                                        }
                                    });
                                }
                            }
                        });
                    }
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "查看报名情况",
                    iconCls: 'array-grid-buy-col'
                }),
                new Ext.menu.Separator(),
                new Ext.menu.Item({
                    text: "删除",
                    iconCls: 'array-grid-buy-col'
                })
            ]
        });
        treeMenu.showAt(e.getPoint());
    },
    //编辑行
    bdAction: function (grid, rowIndex, colIndex, item, e, record, row) {

        var rec = grid.getStore().getAt(rowIndex);

        var me = this;

        var win = Ext.create("Admin.ux.Window", {
            width: 710,
            height: 550,
            animateTarget: row,
            items: {xtype: 'tenderpeople-view'},
            buttons: [
                {
                    text: '保存',
                    ui: 'soft-green',
                    iconCls: 'x-fa 	fa-floppy-o',
                    handler: function (btn) {
                        //var form = btn.up("window").down("form").getForm();
                        // Ext.create('Admin.ux.Action').submit(form,'/user/edit',me.getView(),win);
                    }
                },
                {
                    text: '重置',
                    ui: 'soft-red',
                    iconCls: 'x-fa 	fa-mail-reply',
                    handler: function (btn) {
                        /* var form = btn.up("window").down("form");
                         form.getForm().load({
                             url: '/user/get',
                             waitMsg:'加载中...',
                             params: {
                                 id: rec.get('id')
                             },
                             success:function(){
                                 form.down('textfield[id=user_id]').setReadOnly(true);
                             },
                             failure: function(form, action) {
                                 if(action.result.msg!=undefined){
                                     Ext.Msg.alert("提示", "<font color=red>"+action.result.msg+"!</font>");
                                 }else{
                                     Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                 }
                             }
                         });
                         form.loadRecord(rec);*/
                    }
                },
                {
                    text: '取消',
                    ui: 'gray',
                    iconCls: 'x-fa 	fa-ban',
                    handler: function (btn) {
                        btn.up("window").close();
                    }
                }
            ]
        });

    },
    //编辑行
    editAction:function(rec,me){


        var win = Ext.create("Admin.ux.Window",{
            title:'编辑招标信息',
            width:710,
            height:550,
            animateTarget: row,
            items:{xtype:'tenderedit-form'},
            buttons:[
                {
                    text:'保存',
                    ui: 'soft-green',
                    iconCls: 'x-fa 	fa-floppy-o',
                    handler:function(btn){
                        var form = btn.up("window").down("form").getForm();
                        Ext.create('Admin.ux.Action').submit(form,'/tender/edit',me.getView(),win);
                    }
                },
                {
                    text:'重置',
                    ui: 'soft-red',
                    iconCls: 'x-fa 	fa-mail-reply',
                    handler:function(btn){
                        var form = btn.up("window").down("form");
                        form.getForm().load({
                            url: '/tender/get',
                            waitMsg:'加载中...',
                            params: {
                                id: rec.get('id')
                            },
                            success:function(){
                                form.down('textfield[id=id]').setReadOnly(true);
                            },
                            failure: function(form, action) {
                                if(action.result.msg!=undefined){
                                    Ext.Msg.alert("提示", "<font color=red>"+action.result.msg+"!</font>");
                                }else{
                                    Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                                }
                            }
                        });
                        form.loadRecord(rec);
                    }
                },
                {
                    text:'取消',
                    ui: 'gray',
                    iconCls: 'x-fa 	fa-ban',
                    handler:function(btn){
                        btn.up("window").close();
                    }
                }
            ],

            listeners:{
                show:function(w,opts){

                    var form = this.down('form');

                    form.getForm().load({
                        url: '/tender/get',
                        waitMsg:'加载中...',
                        params: {
                            id: rec.get('id')
                        },
                        success:function(){
                            form.down('textfield[id=id]').setReadOnly(true);
                        },
                        failure: function(form, action) {
                            if(action.result.msg!=undefined){
                                Ext.Msg.alert("提示", "<font color=red>"+action.result.msg+"!</font>");
                            }else{
                                Ext.Msg.alert("提示", "<font color=red>加载出错,请刷新页面重试!</font>");
                            }
                        }
                    });
                }
            }
        });

    },
    //删除行
    removeAction: function (grid, rowIndex, colIndex, item, e, record, row) {
        var rec = grid.getStore().getAt(rowIndex);
        var _id = rec.data.id;
        Ext.create('Admin.ux.Action').remove({id: _id}, '/user/delete', this.getView(), row);
    },
    //重置密码
    resetPassAction: function (grid, rowIndex, colIndex, item, e, record, row) {

        Ext.create('Admin.ux.form.TextEditable', {
            submitUrl: '/user/resetpwd',
            //cmpt:grid,
            submitName: 'new_pwd',
            compTitle: '重置密码',
            emptyText: '请输入新密码',
            animateTarget: row,
            extValue: {id: record.get('id')}
        }).show();
    }
});